home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 5 / CHASSIS_ / __READ.ME next >
Text File  |  1992-06-11  |  9KB  |  109 lines

  1. Chassis
  2.  
  3. by Chuck Hoffman
  4.  
  5. Chassis is a sample Macintosh application program which you can use as a foundation, or ╥chassis╙ for your own code.  It is written in C, and is compiled with THINK C from Symantec Corporation.
  6.  
  7. If you are not already familiar with Chassis, you might want to take a look at the following things before looking at other parts of the code.
  8. Ñ  The high level flow chart (in MacDraw format)
  9. Ñ  The header file
  10. Ñ  The main program segment
  11.  
  12.  
  13. CONVERTING ╥CHASSIS╙ TO YOUR OWN APPLICATION
  14.  
  15. This document will show you a step by step procedure which you can use to convert the Chassis application into an application of your own.
  16.  
  17. It takes about 45 minutes for an experienced Macintosh user, who is familiar with ResEdit and THINK C, to go through this procedure, (provided you don't spend a lot of time editing the icons).
  18.  
  19. You will need the following software:
  20. Ñ    ResEdit, from the Apple Programmers and Developers Association (APDA) version 2.1 or later.  This example uses version 2.1.1.
  21. Ñ    A current Macintosh operating system, version 6.0.4 or later.  This example uses 7.0.1.
  22. Ñ    THINK C, from Symantec Corporation, version 5.0 or later.  This example uses 5.0.1.
  23.  
  24. 1.  First, copy the ╥Chassis ─╙ folder to your system, and give it the name of your new application.  In this exercise, we will name the new application ╥NewOne╙ so the folder name will be ╥NewOne ─╙.
  25.  
  26. 2.  If you are not already familiar with the Chassis program, double click on its icon to run it.  When you are through, drag the Chassis program to the Trash, and delete it from your system.  It is important that it be completely removed from your system, and not just renamed or kept in the Trash.
  27.  
  28. 3.  Most of the changes will be made to the project resource file.  Double click on the ResEdit document ╥MyProj.╣.rsrc╙, which will open it and launch ResEdit.
  29.  
  30. 4.  Edit 'DITL' resource number 128.  This is the ╥About╙ dialog item list.  Do this by double clicking on the 'DITL' resource type in the ╥MyProj.╣.rsrc╙ window, then double clicking on ID 128 in the ╥DITLs from MyProj.╣.rsrc╙ window.
  31.  
  32. 5.  After the DITL window opens, double click on item 2, and change the text from ╥About Chassis╙ to ╥About NewOne╙.
  33.  
  34. NOTE:  The font you see in ResEdit in this step will not be the Geneva 10 font which the user will see, so don't worry about seemingly incorrect spacing.  (You can see the Geneva 10 spacing by using the ╥View As╔╙ item on the ╥DITL╙ menu.)
  35.  
  36. 6.  Go back to the first ResEdit window and select 'WIND' resource number 128.  This is the main window.  When the 'WIND' resource window opens, select ╥Set 'WIND' Characteristics╙ from the 'WIND' menu, and change the window title from ╥Chassis╙ to ╥NewOne╙.
  37.  
  38. 7.  Go back to the main ResEdit window and select 'MENU' resource number 128.  This is the top of the ╥Apple╙ menu.  When the 'MENU' window opens, single click on the first and second items in the list, and change the texts to ╥About NewOne╔╙ and ╥Help for NewOne╔╙.
  39.  
  40. 8.  Now select 'MENU' resource number 131.  This is the program's own menu.  Change the title to ╥NewOne╙.
  41.  
  42. 9.  Next, edit two ╥families╙ of desktop icon resources.  First, go back to the main ResEdit window and select 'ICN#' resource number 128.  This is the family of program icons which will be visible on the desktop.  A window for editing all icons in the family will open.
  43.  
  44. 10.  Edit all the icons and the mask so they will be your own icons.  Select different icons for editing by single clicking on the boxes containing the various icons and masks.  They are to the right of the center of the window.
  45.  
  46. 11.  Do the same thing for desktop icon resource family 129.  This is the icon family for TEXT documents created by the program.
  47.  
  48. 12.  Now do the same thing for the program's internal icons by going back to the main ResEdit window, and selecting 'cicn' resource number 128.
  49.  
  50. 13.  Next, we need to edit the 'BNDL' (╥bundle╙) resource, which is used by the Finder when launching the program or opening or printing a document.  Go to the main ResEdit window and select resource type 'BNDL' number 128.  When the 'BNDL' resource window opens, select ╥Extended view╙ from the BNDL menu.  Change the signature from 'chAS' to a four character signature of your own.  We will use 'nEw1' for this example.  (NOTE - If you are going to distribute this program, you will need to register the signature with Developer Support at Apple Computer.  'chAS' is registered with Apple as the signature for Chassis.)
  51.  
  52. 14.  Change the version number to a different one of a standard format.  The first digit is your major version number.  The second is your minor version number, and the third is your revision number for bug fixes.  Instead of a period between the second and third digit, you can use ╥d╙ for a Development version, or ╥a╙ or ╥b╙ for an Alpha or Beta test release.  The first development version of things I create is usually ╥1.1d1╙.  Refer to Tech Note #189 for more information.
  53.  
  54. 15.  Put your own name in where you see ╥(put name here)╙ in the copyright string.  For this example we will use the name ╥J.B. Fletcher.╙
  55.  
  56. NOTE:  If you are programming for a company (for hire) you probably are required to use the company name.
  57.  
  58. 16.  Now go back to the main ResEdit window, and select resource type 'vers', number 1.  This is the version information you see when you use ╥Get Info╙ from the Finder.  When the 'vers' resource window opens, make all the appropriate changes, and select ╥Development╙ from the pop-up menu.
  59.  
  60. 17.  Now quit from ResEdit, saving the changes you have made.
  61.  
  62. 18.  The next thing to do is to get a fresh precompile of the header file for NewOne.  Double click on the ╥MyIncludes.c╙ document icon.
  63.  
  64. 19.  You will be prompted for the name of a THINK C project file.  ╥MyProj.╣╙ will already be selected in the window.  This is fine.  Just click on the ╥Open╙ button.
  65.  
  66. 20.  When the ╥MyIncludes.c╙ window opens, select ╥Precompile╙ from the Source menu.
  67.  
  68. 21.  When the precompile has completed, save the output as ╥MyPrecompIncludes╙ in the folder ╥NewOne ─╙.  You must get the spelling and capitalization of the name ╥MyPrecompIncludes╙ exactly right in order for things to compile later.  When prompted, respond to replace the existing version.
  69.  
  70. 22.  Close the source window for ╥MyIncludes.c╙.  The window for the project file ╥MyProj.╣╙ will remain open after the ╥MyIncludes.c╙ window closes.
  71.  
  72. 23.  Now we will make a few small changes to the source.  First, double click on the ╥Main.c╙ line in the ╥MyProj.╣╙ project window.  The main program source code will open up.  Change the name, version number, and author name in the comments.
  73.  
  74. 24.  Close the ╥Main.c╙ window, and open the ╥MainDrawProc.c╙ source code window.  Find the call to ╥DrawString╙ and change the Pascal character string from ╥/pChassis╙ to ╥/pNewOne╙.
  75.  
  76. 25.  Close the ╥MainDrawProc.c╙ window, and open the ╥FileSaveProc.c╙ source code window.  Find the ╥Create╙ call, and change the creator signature from 'chAS' to the 'nEw1' signature you put into the 'BNDL' resource.
  77.  
  78. 26.  Close the ╥FileSaveProc╙ window, and select ╥Set Project Type╙ from the Project menu.  When the Project Type dialog window opens, set the ╥Creator╙ value to the same 'nEw1' signature you put into the 'BNDL' resource.
  79.  
  80. 27.  Now we will actually build the application program.  Select ╥Build Application╙ from the Project menu, and respond ╥Yes╙ when you get the prompt about bringing the project up to date.
  81.  
  82. 28.  Save the application with the ╥NewOne╙ name.  In a few seconds, the ╥NewOne╙ application icon should appear in the ╥NewOne ─╙ window.
  83.  
  84. 29.  Quit out of THINK C.
  85.  
  86. 30.  Now test your changes.  ╥Get Info╙ from the Finder's File menu should show your 'vers' information and the large icon.
  87.  
  88. 31.  When you launch the program, you should see the ╥NewOne╙ name in large, bold letters, the large icon (in color if you have a color monitor), and your version information on the main window.  The window title also should be "NewOne╙.  You should also see ╥NewOne╙ in the menu bar, and, if you are running MultiFinder or System 7, the small icon should appear at the right end of the menu bar.
  89.  
  90. 32.  The Apple menu should show the ╥NewOne╙ name in the ╥About╙ and ╥Help╙ items.
  91.  
  92. 33.  The About dialog should be titled ╥About NewOne╙ and should display the large icon and your version information.
  93.  
  94. 34.  If you create and save a new document, your document icon should appear in a few seconds in the ╥NewOne╩─╙ folder.
  95.  
  96. 35.  Quit out of the application, then make any other modifications you want.
  97.  
  98. 36.    If you decide later that you want to change an icon, or to add more icons for output files, follow these steps:
  99.  
  100. 1)    Make your changes to the icons.
  101. 2)    Delete all copies the program (not the C file, just the executable program) even if the copies have been renamed to something else.  Delete, don't save in the Trash.
  102. 3)    Use THINK C to build the application again.
  103. 4)    Restart your computer while holding down the command and option keys to rebuild the desktop file on the hard disk where your program is.
  104. NOTE:    If you are using MultiFinder with Macintosh operating system version 6.0.4 through 6.0.8, turn MultiFinder off first.  It is in the Startup Option item of the Special menu.  Turn MultiFinder back on again after you have rebuilt the desktop file.
  105.  
  106. Good luck.  Call me if you have any questions or comments about this procedure.  I will appreciate hearing from you.
  107.  
  108. - Chuck Hoffman
  109.